package com.lyh.servlet;

import com.lyh.service.BookService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 功能
 * 作者：lyh
 * 日期：2024/8/8 15:19
 */
@WebServlet("/del")
public class DelBook extends HttpServlet {
    BookService bookService = new BookService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String ids = request.getParameter("ids");
        String[] split = ids.split("-");
        for (String id : split) {
            bookService.deleteById(Integer.parseInt(id));
        }
        response.sendRedirect(request.getContextPath()+"/show");
    }
}
